<?php
require_once("config_inc.php");

require_once("core/user_api.php");
require_once("core/gui_api.php");
require_once("core/share_api.php");

$db = new database();
$db->connect();

session_start();

$share_api = new share_api($db);
$gui_api = new gui_api($db);

$project_data = $share_api->get_project($_GET["project_id"]);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?=$project_data["PRJ_NAME"]?> - Untitled Document</title>
<?php require_once("meta_inc.php"); ?>
<script type="text/javascript">

var server_url = '<?=SERVER_URL;?>';

$(document).ready(function() {	
	$("#input-comment-user").autoResize({extraSpace: 1, maxHeight : 150 });
});
</script>
</head>
<body>
<?php require_once("topbar_inc.php"); ?>

<div class="wrapper" style="margin-top:80px">	

	<div class="left-column-right">
    	<div class="small-white-page input-form">
			<div class="sub-gray-title">recommended</div>
			<?=$gui_api->insert_feed_list(FEED_TYPE_RECOMENDED, 3);?>
			<?php if(is_active_user_session()) { ?>
            <div class="sub-gray-title">subscriptions</div>
			<?=$gui_api->insert_feed_list(FEED_TYPE_SUBSCRIPTION, 3);?>
			<?php } ?>
			<table cellpadding="4" cellspacing="0">
            	<tr>
                	
                </tr>
                <tr>
                	<td align="right"><span class="small-info-text">category</span></td>
                    <td><a href="<?=SERVER_URL?>/category/"><?=$project_data["CAT_NAME"]?></a></td>
                </tr>
                <tr>
                	<td align="right"><span class="small-info-text">date</span></td>
                    <td><?=translateDateTime($project_data["PRJ_DATE"], DATE_TRANSLATE_NORMAL)?></td>
                </tr>
            </table>          
            <a href="<?=SERVER_URL?>/edit/<?=$_GET["project_id"]?>">edit</a>                   
        </div>
    </div>

	<div class="right-column-right">
    	<div class="input-form big-white-page">
	        <h2><?=$project_data["PRJ_NAME"]?></h2>
			
		<?php if($project_data["PRJ_TYPE"] == PROJECT_TYPE_IMAGE) { ?>
			<p class="project-holder"><img src="<?=SERVER_URL . GALLERY_PHOTO_PATH . $project_data["PRI_FILENAME"]?>" /></p>   
		<?php } else if($project_data["PRJ_TYPE"] == PROJECT_TYPE_VIDEO) { ?>
    
			<?php if($project_data["PRV_TYPE"] == VIDEO_YOUTUBE_TYPE) { ?>
			<p><iframe width="725" height="410" src="http://www.youtube.com/embed/<?=$project_data["PRV_VIDEO"]?>?rel=0" frameborder="0" allowfullscreen></iframe></p>
            <?php } else if($project_data["PRV_TYPE"] == VIDEO_VIMEO_TYPE) { ?>
				<p><iframe src="http://player.vimeo.com/video/<?=$project_data["PRV_VIDEO"]?>?title=0&amp;byline=0&amp;portrait=0" width="725" height="410" 
					frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
            <?php } ?>
        
        
        <?php } ?>                        
            <p class="default-text"><?=$project_data["PRJ_DESC"]?></p>
			<table class="input-form" cellpadding="5" cellspacing="5">
				<tr>
					<td align="right"><span class="small-info-text">author</span></td>
                    <td><a href="<?=SERVER_URL?>/profile/<?=$project_data["USR_ID"]?>"><?=$project_data["USR_NAME"]?></a></td>
				</tr>
			</table>
        </div>
        
        <div class="input-form big-white-page" style="margin-top:20px">
        	<?php if(is_active_user_session()) { ?>
        	<div class="comment-box">
		        <a href="<?=SERVER_URL?>/profile/<?=$project_data["USR_ID"]?>" class="profile-image"><img src="<?=SERVER_URL?>gfx/user-empty.png" /></a>
    	        <textarea  id="input-comment-user" style="float:left;width:641px" placeholder="your comment..."></textarea>
                <div class="clear"></div>
                <p style="text-align:right;"><button onClick="_gui_control.on_submit_comment(<?=$_GET["project_id"]?>, this, event);">publish</button></p>                	
            </div>
            <?php } ?>
            
			<div id="comments_holder"><?php echo $gui_api->insert_forum_list($_GET["project_id"], 0); ?></div>
			<div id="paginator_holder" style="text-align:center"><?php echo $gui_api->insert_forum_pagination($_GET["project_id"], 0); ?></div>
        </div>
    
    
    </div>

    

    <div class="clear"></div>

	
</div>

<?php require_once("bottombar_inc.php"); ?>	
</body>
</html>
<?php $db->close(); ?>